package com.books.service.connection.impl;


import com.books.mapper.connection.ConnectionMapper;
import com.books.model.entity.backcontroller.Connection;
import com.books.service.connection.IConnectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class ConnectionServiceImpl implements IConnectionService {
    @Autowired
    private ConnectionMapper connectionMapper;
    @Autowired Connection connection;


    @Override
    public List<Connection> connection(Integer peopleId) {
        List<Connection> connectionList = connectionMapper.connection (peopleId);
        return connectionList;
    }

    @Override
    public void del(Integer id) {
        connectionMapper.del (id);
    }

    @Override
    public void addConnection(Connection connection) {
        connectionMapper.addConnection(connection);
    }

    @Override
    public void delByAll(Integer peopleId, Integer bookId, Integer bookType) {
        connectionMapper.delByAll(peopleId,bookId,bookType);
    }

    @Override
    public boolean ifCollect(Integer peopleId, Integer bookId, Integer bookType) {
        Connection connection = connectionMapper.findByAll(peopleId,bookId,bookType);
        if (connection!=null){
            return true;
        }else {
            return false;
        }
    }


}
